<template>
    <van-nav-bar title="搜索" left-text="返回" left-arrow @click-left="() => { $router.back('/') }" />
    <van-search v-model="values" shape="round" placeholder="请输入搜索关键词" />
    <template v-if="values.length == 0 || sousuoData.length == 0">
        <van-empty description="内容为空" />
    </template>

    <!-- 商品卡片 -->
      <template v-else>
        <router-link v-for="item in sousuoData" :to="'/xiangqing/'+item.goods_id">
            <van-card  :title="item.goods_name" />
        </router-link>
      </template>
   

</template>

<script setup>
import { ref,watch} from 'vue';
const sousuoData = ref([])
const values = ref('')
import _ from 'lodash'
import { sousuoApi } from '@/api/api'
watch(values,_.debounce((values)=>{
    console.log(values)
    sousuoApi(values).then(res=>{
        console.log('搜索',res)
         sousuoData.value=res.data.message
    })
},3000))
</script>

<style lang="scss" scoped></style>